package com.example.goodpet.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.util.Log;

import java.util.List;

public class DeviceUtil {
    /** 判断手机中是否安装指定包名的软件 */
    public static boolean isInstall(Context context, String name) {
        List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(0);
        for (int i = 0; i < packages.size(); i++) {
            PackageInfo packageInfo = packages.get(i);
//            Log.e("TAG", "isInstall: "+packageInfo.packageName );
            if (packageInfo.packageName.equals(name)) {
                return true;
            } else {
                continue;
            }
        }
        return false;
    }
}
